package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	UserId      int     `gorm:"type:int(10);not null;comment:'用户id'"`
	GoodsId     int     `gorm:"type:int(10);not null;comment:'课程id'"`
	OrderSn     string  `gorm:"type:varchar(50);not null;comment:'订单号'"`
	CouRseName  string  `gorm:"type:varchar(50);not null;comment:'课程名称'"`
	CouRsePrice float64 `gorm:"type:double(10,2);not null;comment:'课程价格'"`
	CouResInter string  `gorm:"type:varchar(255);not null;comment:'课程介绍'"`
	OrderStatus int     `gorm:"type:int(10);not null;comment:'支付状态: 1:未支付 2:超时未支付 3:已支付 4:支付完成'"`
}

func CreateOrder(order *Order) error {
	return DB.Debug().Create(&order).Error
}

func UpdateStatus(Ordersn string, status int) error {
	return DB.Debug().Where("order_sn= ?", Ordersn).Update("order_status", status).Error
}
